Skip to content

Fix syntax of two programs (powint and binarysearch) and add powint-erroneous#71

Merged
kostis merged 2 commits intokostis:masterfrom
orestis42:master
Apr 16, 2025
Merged

Fix syntax of two programs (powint and binarysearch) and add powint-erroneous#71
kostis merged 2 commits intokostis:masterfrom
orestis42:master

Conversation

@orestis42
Copy link
Contributor

Use"=" instead of "==" for equality and moved "var temp is int" declaration to the beginning of the block. The program still contains a semantic error so I copied it to the dana/programs-erroneous directory.

Use"=" instead of "==" for equality and moved "var temp is int"
declaration to the beginning of the block. The program still contains a
semantic error so I copied it to the dana/programs-erroneous directory.
@kostis kostis changed the title Fix syntax of powint.dana add powint-erroneous.dana Fix syntax of two programs (powint and binarysearch) and add powint-erroneous Apr 16, 2025
@kostis
Copy link
Owner

kostis commented Apr 16, 2025

Thanks for these fixes. However, I think it would be better to also fix the semantic error(s) of powint somehow before this gets merged to the repository.

Adjusted the bAdded a missing comma in a procedure call, changed
function calls to use () instead of :, specifed a fixed size for the
local array variable declaration, and corrected the assignment operator
from "=" to ":=".
@orestis42
Copy link
Contributor Author

orestis42 commented Apr 16, 2025

Initially, I believed there was a semantic error when passing the local variable temp to the powint function's result parameter. I assumed that because result was declared as ref int, the variable passed to it also needed to be explicitly marked as a reference. However, upon revisiting the Dana specification, particularly section 1.4.4 Calling structural units as functions I realized this assumption was wrong. The rule only requires the argument provided during the call to be an l-value of the appropriate type. Since temp is indeed an l-value of type int, passing it to the ref int parameter is semantically correct.

@kostis
Copy link
Owner

kostis commented Apr 16, 2025

OK - thanks for looking into this and your contribution!

I will merge the PR.

@kostis kostis merged commit 2c09248 into kostis:master Apr 16, 2025
2 checks passed
@orestis42
Copy link
Contributor Author

orestis42 commented Apr 16, 2025

Please also remove powint-erroneous.dana since it is not erroneous.
If I find any other syntax/lexical errors in the Dana programs should I attempt to fix them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants